package my.cloud.study.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import feign.Retryer;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignConfig {

    /**
     * The default feign retry was never which was been defined
     * in {@link FeignClientsConfiguration#feignRetryer()}
     *
     * @return the {@link Retryer}, it will retry 5 times, and each retry will cost 1 seconds. The period of each
     * retry is 100 millseconds.
     */
    @Bean
    public Retryer feignRetryer() {
        return new Retryer.Default();
    }

    @Bean
    public IRule ribbonRule(){
        return new RandomRule();
    }
}
